﻿<?php

$title = isset($_POST['title'])?$_POST['title']:'Mr';
$name = $_POST['name'];
$firstname = $_POST['firstname'];
$address = $_POST['address'];
$postalCode = $_POST['postalCode'];
$city = $_POST['city'];
$phone = $_POST['phone']; 
$mail = $_POST['mail'];
$password = $_POST['password'];

$customer = array(
        "title" => $title, 
        "name" => $name, 
        "firstname" => $firstname, 
        "address" => $address, 
        "postalCode" => $postalCode, 
        "city" => $city, 
        "phone" => $phone, 
        "mail" => $mail,
		"password" => $password);
		
$smarty->assign("customer", $customer);
$smarty->assign("customerJson", urlencode(json_encode($customer)));
		
if(!isset($_POST['deliveryAdress'])){
	$titleDelivery = $_POST['title'];
	$nameDelivery = $_POST['nameDelivery'];
	$firstnameDelivery = $_POST['firstnameDelivery'];
	$addressDelivery = $_POST['addressDelivery'];
	$postalCodeDelivery = $_POST['postalCodeDelivery'];
	$cityDelivery = $_POST['cityDelivery'];
	$phoneDelivery = $_POST['phoneDelivery']; 
} else {
	$titleDelivery = "";
	$nameDelivery = $name;
	$firstnameDelivery = $firstname;
	$addressDelivery = $address;
	$postalCodeDelivery = $postalCode;
	$cityDelivery = $city;
	$phoneDelivery = $phone; 
}

$customerBis = array(
		"titleDelivery" => $titleDelivery, 
		"nameDelivery" => $nameDelivery, 
		"firstnameDelivery" => $firstnameDelivery, 
		"addressDelivery" => $addressDelivery, 
		"postalCodeDelivery" => $postalCodeDelivery, 
		"cityDelivery" => $cityDelivery, 
		"phoneDelivery" => $phoneDelivery);
		
$smarty->assign("customerBis", $customerBis);

if(isset($_POST['deliveryAdress'])){
	$smarty->assign("customerBisJson", NULL);
} else {
	$smarty->assign("customerBisJson", urlencode(json_encode($customerBis)));
}

$smarty->display('account_recap.tpl');
